//home模块仓库
import {reqCategoryList,reqGetBannerList,reqGetFloorList} from '@/api'

const state= {
    categoryList:[], //商品分类
    bannerList:[],//首页轮播数据
    floorList:[]//楼层数据
};
const mutations= {
    CATEGORYLIST(state,categoryList){
        state.categoryList= categoryList 
    },
    BANNERLIST(state,bannerList){
        state.bannerList= bannerList        
    },
    FLOORLIST(state,floorList){
        state.floorList= floorList
    }
};
const actions= {
    //api函数请求调用，向服务器发请求
    async catgoryList({commit}){
        let result = await reqCategoryList();
        if(result.code == 200){
            commit("CATEGORYLIST",result.data)
        }
    },
    //获取首页轮播图数据
    async getBannerList({commit}){
        let result = await reqGetBannerList();
        console.log(result)
        if(result.code == 200){
            commit("BANNERLIST",result.data)
        }
    },
    //获取floor数据
    async getFloorList({commit}){
        let result = await reqGetFloorList();
        if(result.code == 200){
            commit("FLOORLIST",result.data)
        }
     }
};
const getters= {};
export default({
    state,//数据存放
    mutations,//修改state数据
    actions,//业务逻辑
    getters,//计算属性
   
})